package com.kevinxiaoge.ruoli.demo;

/**
 * 饿汉式
 *
 * @author chengyuanyuan
 */
public class Singleton {

    private final static Singleton singleton= new Singleton();

    private Singleton(){

    }

    public static Singleton getInstance() {
        return singleton;
    }
}

class SingletonTest {
    public static void main(String[] args) {
        Singleton instance = Singleton.getInstance();
        Singleton instance1 = Singleton.getInstance();
        System.out.println(instance == instance1);
    }
}
